import re


class Solution:
    def convert(self, s, numRows):
        """
        :type s: str
        :type numRows: int
        :rtype: str
        """
        if numRows == 1:
            return s
        i, j = 0, 0
        tmp = ["" for x in range(numRows)]
        for val in s:
            if 0 < i < numRows-1:
                tmp[i] = tmp[i]+val
                if j == 0:
                    i = i+1
                else:
                    i = i-1
            elif i == numRows-1:
                tmp[i] = tmp[i] + val
                i = i-1
                j = 1
            elif i == 0:
                tmp[i] = tmp[i] + val
                i = i+1
                j = 0
        s_result = ""
        for v in tmp:
            s_result = s_result+v
        return s_result

    def isMatch(p, s):
        pattern = re.match(p, s)
        if pattern is not None:
            return pattern.group() == s
        return False

sol = Solution()
#nums, target = "LEETCODEISHIRING", 3
nums, target = "AB", 1
res = sol.convert(nums, target)

s = "mississippi"
p = "mis*is*p*."
res2 = sol.isMatch(p, s)
print(res2)
print(res)
